package cl.regalloc.parse;

import java.util.HashMap;

public class LabelFactory {

	private static HashMap<String, Label> labelSet = new HashMap<String, Label>();

	public LabelFactory() {
		super();
	}

	public static Label getLabel(String operand) {
		if (labelSet.containsKey(operand)) {
			System.out.printf("label \"%s\" already exists, returnign reference...%n", operand);
			return labelSet.get(operand);
		} else {
			System.out.printf("creating label \"%s\"...%n", operand);
			Label currentLabel = new Label(operand);
			labelSet.put(operand, currentLabel);
			return currentLabel;
		}
	}

}
